package com.quickd.web.controller.wms;

import com.quickd.core.annotation.LogOperationAno;
import com.quickd.core.common.JsonResult;
import com.quickd.core.secure.SecureUtil;
import com.quickd.core.validator.ValidatorUtils;
import com.quickd.core.validator.group.AddGroup;
import com.quickd.service.entity.wms.Form;
import com.quickd.service.dto.wms.FormDTO;
import com.quickd.service.service.wms.IFormService;
import com.quickd.sys.jwt.JwtUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.quickd.core.controller.BaseController;
import io.swagger.annotations.Api;
/**
 * 单据
 *
 * @author quickd quickd@dacanginfo.com
 * @since 2019-10-07
 */
@RestController
@RequestMapping("wms/form")
@Api(tags="单据")
public class FormController extends BaseController<IFormService, Form,FormDTO> {



    @PostMapping("addIo")
    @ApiOperation("添加入库单")
    @LogOperationAno("添加入库单")
    public JsonResult addIo(@RequestBody FormDTO dto) {
        dto.setType(0);
        dto.setOperator(SecureUtil.getCurrentUser().getUsername());
        ValidatorUtils.validateEntity(dto, new Class[]{AddGroup.class});
        baseService.addForm(dto);
        return (new JsonResult()).ok("成功添加数据");
    }
    @PostMapping("addMio")
    @ApiOperation("添加盘点单")
    @LogOperationAno("添加盘点单")
    public JsonResult addMio(@RequestBody FormDTO dto) {
        dto.setType(3);
        dto.setOperator(SecureUtil.getCurrentUser().getUsername());
        ValidatorUtils.validateEntity(dto, new Class[]{AddGroup.class});
        baseService.addForm(dto);
        return (new JsonResult()).ok("成功添加数据");
    }
    @PostMapping("addOo")
    @ApiOperation("添加出库单")
    @LogOperationAno("添加出库单")
    public JsonResult addOo(@RequestBody FormDTO dto) {
        dto.setType(1);
        dto.setOperator(SecureUtil.getCurrentUser().getUsername());
        ValidatorUtils.validateEntity(dto, new Class[]{AddGroup.class});
        ValidatorUtils.validateEntity(dto, new Class[]{AddGroup.class});
        baseService.addForm(dto);
        return (new JsonResult()).ok("成功添加数据");
    }

    @PostMapping("addTo")
    @ApiOperation("添加移库单")
    @LogOperationAno("添加移库单")
    public JsonResult addTo(@RequestBody FormDTO dto) {
        dto.setType(2);
        dto.setOperator(SecureUtil.getCurrentUser().getUsername());
        ValidatorUtils.validateEntity(dto, new Class[]{AddGroup.class});
        ValidatorUtils.validateEntity(dto, new Class[]{AddGroup.class});
        baseService.addForm(dto);
        return (new JsonResult()).ok("成功添加数据");
    }

}